#include<iostream>
#include<unistd.h>
#include<signal.h>
using std::cout;
using std::endl;

void handler(int signum)
{
    cout<<"I catch a signal::"<<signum<<endl;
    sigset_t pending;
    while(true){
        sigpending(&pending);
        int sig=1;
        for(sig=1;sig<=31;sig++){
            if(sigismember(&pending,sig))
            {
                cout<<"1";
            }
            else{
                cout<<"0";
            }
        }
        cout<<endl;
        sleep(1);
        }
}
int main()
{
    struct sigaction act,oact;
    act.sa_handler=handler;
    act.sa_flags=0;
    sigemptyset(&act.sa_mask);
    sigaddset(&act.sa_mask,3);

    sigaction(2,&act,&oact);
    
    while(true)
    {
        cout<<"I am a process!My pid::"<<getpid()<<endl;
        sleep(1);
    }

    return 0;
}
